package com.platform.util;

import com.alibaba.fastjson.JSONObject;
import com.platform.constants.SmsPlatformConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Component
public class SmsUtil {

    //发送赛油短信 content是短信内容 发送的时候注意加上前置的短信签名
    public int sendSaiYou(String phone, String content) {
        Map<String, String> map = new HashMap<>();
        map.put("appid", "24662");
        map.put("to", phone);
        map.put("content", content);
        map.put("signature", "fed064a1d28a4aae378e8e06f18ee901");
        int flag = -1;
        try {
            String jsonResult = HttpClientUtil.postRequest(SmsPlatformConstants.SAIYOU_SMS_JSONURL, map);
            JSONObject jsonObject = JSONObject.parseObject(jsonResult);
            if (jsonObject.getString("status").equals("success")) {
                flag = 1;
            }
        } catch (Exception e) {
            log.error("-------赛油短信发送失败--------");
        }
        return flag;
    }

}
